// 题目链接：https://www.luogu.com.cn/problem/P1873
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1000010;
int n, m;
int arr[N];

int binary_search(int arr[], int len, int num, int highest)
{
    int l = -1, r = highest;
    int mid;
    long long cnt;
    while (l + 1 < r)
    {
        mid = (l + r) / 2;
        cnt = 0;
        for (int i = 0; i < len; ++i)
        {
            cnt += max(0, arr[i] - mid);
        }

        if (cnt >= num)
            l = mid;
        else
            r = mid;
    }
    return l;
}

int main()
{
    int highest = 0;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &arr[i]);
        highest = max(arr[i], highest);
    }

    int ret = binary_search(arr, n, m, highest);
    printf("%d", ret);

    return 0;
}